<?php
/**
 * XiteCode form widget
 *
 * Use:<br />
 * <code>
 * {Form id="id" [method="method" [action="action"]]}
 * {/Form}
 * </code>
 */

function smarty_block_Form($params, $content, &$Smarty, &$repeat)
{
  $method = 'post';
  $action = $_SERVER['REQUEST_URI'];

  if (empty($params['id'])) {
    return 'You must supply an id to the {Form} widget.';
  }

  if (!empty($params['method'])) {
    $method = $params['method'];
  }

  if (!empty($params['action'])) {
    $action = LINK_ROOT.$params['action'];
  }

  $Smarty->_currentForm = $params['id'];

  return '<form id="'.$params['id'].'" name="'.$params['id'].'" method="'.$method.'" action="'.$action.'">'.$content.'<small>Required fields are marked with a <span class="required">*</span></small></form>';

}
